﻿using Models.Models.Sugar;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Repositories.Base
{
    public interface IBaseRepository<T> where T : class, new()
    {
        int Add(T entity);
        int Add(List<T> entities);
        int Update(T entity);
        int Update(List<T> entities);
        int Delete(T entity);
        int Delete(List<T> entities);
        int Delete(Expression<Func<T, bool>> deleteExpression);
        T Find(Expression<Func<T, bool>> findExpression);
        PageModel<T> GetPaged(Expression<Func<T, bool>> whereExpression, int page, int limit);
        PageModel<T> GetPaged(Expression<Func<T, bool>> whereExpression, Expression<Func<T, object>> orderExpression, OrderByType orderByType, int page, int limit);
        List<T> GetList(Expression<Func<T, bool>> whereExpression);
        List<T> GetList(Expression<Func<T, bool>> whereExpression,Expression<Func<T,object>> orderExpression, OrderByType orderByType= OrderByType.Asc);
        int GetCount(Expression<Func<T,bool>> whereExpression);
        Task<int> AddAsync(T entity);
        Task<int> AddAsync(List<T> entities);
        Task<int> UpdateAsync(T entity);
        Task<int> UpdateAsync(List<T> entities);
        int UpdateExpression(Expression<Func<T, bool>> whereExpression, Expression<Func<T, T>> setColumns);
        int UpdateExpression(Expression<Func<T, bool>> whereExpression,params Expression<Func<T, bool>>[] setColumn);
        Task<int> UpdateExpressionAsync(Expression<Func<T, bool>> whereExpression,Expression<Func<T, T>> setColumns);
        Task<int> UpdateExpressionAsync(Expression<Func<T, bool>> whereExpression, params Expression<Func<T, bool>>[] setColumn);
        Task<int> DeleteAsync(T entity);
        Task<int> DeleteAsync(List<T> entities);
        Task<int> DeleteAsync(Expression<Func<T, bool>> deleteExpression);
        Task<T> FindAsync(Expression<Func<T, bool>> findExpression);
        Task<List<T>> GetListAsync(Expression<Func<T, bool>> whereExpression);
        Task<List<T>> GetListAsync(Expression<Func<T, bool>> whereExpression, Expression<Func<T, object>> orderExpression, OrderByType orderByType = OrderByType.Asc);
        Task<PageModel<T>> GetPagedAsync(Expression<Func<T, bool>> whereExpression, int page, int limit);
        Task<PageModel<T>> GetPagedAsync(Expression<Func<T, bool>> whereExpression, Expression<Func<T, object>> orderExpression, OrderByType orderByType, int page, int limit);
        Task<int> GetCountAsync(Expression<Func<T, bool>> whereExpression);

    }
}
